<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../img/base.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../js/jquery-1.8.2.min.js"></script>
<script language="javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
<script language="javascript">
$(document).ready(function(){
	$('#add_date, #add_time').live('click',function(){
		//alert('before');
		var date_str='';
		
		if($(this).attr('id')=='add_time')
		{
			var count_time = $('#count_time').val();
			var new_time = count_time*1 + 1;
			$('#count_time').val(new_time);
			date_str += '<br/><input  type="text" name="start_time'+new_time+'" id="start_time'+new_time+'" onClick="WdatePicker({dateFmt:\'HH:mm:ss\'})"  /> - <input type="text" name="end_time'+new_time+'" id="end_time'+new_time+'" onClick="WdatePicker({dateFmt:\'HH:mm:ss\'})"  />';
			$('#add_time').before(date_str);
		}
		if($(this).attr('id')=='add_date')
		{			
			var count_input = $('#count_input').val();
			var new_count = count_input*1 + 1;
			$('#count_input').val(new_count);
			date_str += '<br/><input type="text" name="start_date'+new_count+'" id="start_date'+new_count+'" onClick="WdatePicker()"  /> - <input type="text" name="end_date'+new_count+'" id="end_date'+new_count+'" onClick="WdatePicker()"  /> &nbsp;';
			$('#add_date').before(date_str);
		}
	});
});
function checkSubmit(){
	var code = $('#code').val();
	if(code == 'date')
	{
		var start_date = $('#start_date1').val();
		var end_date = $('#end_date1').val();
		
		if(start_date == '' || end_date == '')
		{
			alert('请填写完整日期范围值！');
			return false;
		}
	}
	
	if(code == 'week')
	{
		var week_value = $("input[name='week_value[]']:checked");
		if(week_value.length > 0){
			return true;
		}else{
			alert('请选择星期范围!');
			return false;
		} 
	}
	
	if(code == 'time')
	{
		var start_time = $('#start_time1').val();
		var end_time = $('#end_time1').val();
		
		if(start_time == '' || end_time == '')
		{
			alert('请填写完整时间范围值！');
			return false;
		}
	
	}
	
	return true;
}

function changeValue(){
	var code = $('#code').val();
	var str = '';
	
	if(code == 'all')
	{
		$('#code_info').html('');
	}
	else if(code == 'date')
	{
		str += '<input  type="text" name="start_date1" id="start_date1" onClick="WdatePicker()"  /> - <input type="text" name="end_date1" id="end_date1" onClick="WdatePicker()"  />';
		str += '&nbsp;<input type="button" name="add_date" id="add_date" value="+" />';
		$('#code_info').html(str);
	}
	else if(code == 'week')
	{
		var week_arr = ["日","一","二","三","四","五","六"];
		for(i=0; i<7; i++)
		{
			str +='<input type="checkbox" value="'+i+'" name="week_value[]" />星期'+week_arr[i];
		}
		$('#code_info').html(str);
	}
	else if(code == 'time')
	{
		str +='<input  type="text" name="start_time1" id="start_time1" onClick="WdatePicker({dateFmt:\'HH:mm:ss\'})"  /> - <input type="text" name="end_time1" id="end_time1" onClick="WdatePicker({dateFmt:\'HH:mm:ss\'})"  />';
		str += '&nbsp;<input type="button" name="add_time" id="add_time" value="+" />';
		$('#code_info').html(str);
	}
	
	$('#count_time').val(1);
	$('#count_input').val(1);
}
</script>
<style>
#code_info input {
	margin: 3px;
}
</style>
</head>
<body leftmargin='15' topmargin='10' bgcolor="#FFFFFF">
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0" id="head1" style="border-bottom:1px solid #CCCCCC">
	<tr>
    	<td align='center' valign='top' colspan="2">
            <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D1DDAA">
                <tr>
                    <td height="26" background="../img/newlinebg3.gif">
                        <table width="98%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td align="right">
                                    <input type='button' class="coolbg np" onClick="location='period_scope.php?period_id=<{$period_id}>&mc_cinemaid=<{$cinemaid}>&details_id=<{$details_id}>';" value='返回' />
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
    	<td>
        	<table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr bgcolor="#FFFFFF">
                    <td height="4"></td>
                </tr>
            </table>
        </td>
    </tr>
  	<tr>
    	<td colspan="2">
      		<table width="800" border="0" cellpadding="0" cellspacing="0">
        		<tr>
          			<td width="84" height="24" align="center" background="../img/itemnote1.gif">&nbsp;添加范围&nbsp;</td>
          			<td width="84"></td>
          			<td>&nbsp;</td>
        		</tr>
      		</table>
    	</td>
	</tr>
</table>
<form name="form1" action="period_scope.php" enctype="multipart/form-data" method="post" onSubmit="return checkSubmit()">
<table width="98%"  border="0" align="center" cellpadding="2" cellspacing="2" id="needset">

  	<tr>
    	<td height="24" colspan="4" class="bline">
      		<table width="800" border="0" cellspacing="0" cellpadding="0">
        		<tr>
                    <td width="90">&nbsp;类型：</td>
          			<td width="35%">
                    	<select name="type" <{if $op == 'update'}>disabled="disabled"<{/if}>>
                            <option value="white" <{if $scope_info.scope_type == 'white'}>selected="selected"<{/if}>>白名单</option>
                            <option value="black" <{if $scope_info.scope_type == 'black'}>selected="selected"<{/if}>>黑名单</option>
                        </select>
                    </td>
                    <td width="90">&nbsp;范围：</td>
          			<td width="35%">
                    	<select id="code" name="code" onchange="changeValue()" <{if $op == 'update'}>disabled="disabled"<{/if}>>
                        <{foreach from=$code_list item=code key=key}>
                        	<option value="<{$key}>" <{if $scope_info.scope_code == $code.code_id}>selected="selected"<{/if}>><{$code}></option>
                        <{/foreach}>
                        </select>
                    </td>
        		</tr>
      		</table>      
    	</td>
  	</tr>

    <tr>
    	<td height="24" class="bline">
      		<table width="800" border="0" cellspacing="0" cellpadding="0">
                <tr>
          			<td width="78" >&nbsp;范围值：</td>
          			<td width="722" id="code_info">
                    
                    </td>
                </tr>
      		</table>      
    	</td>
  	</tr>
</table>

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    	<td height="56">
			<table width="98%" border="0" cellspacing="1" cellpadding="1">
        		<tr>
          			<td align="center">
          				<table width="214" border="0" cellspacing="0" cellpadding="0" >
              				<tr>
				                <td width="115">
                                	<input type="hidden" name="count_input" value="1" id="count_input" />
                                    <input type="hidden" name="count_time" value="1" id="count_time" />
                                	<input type="hidden" name="period_id" value="<{$period_id}>" />
                                	<input type="hidden" name="op" value="<{if $op=='add'}>save<{else}>update<{/if}>" />
                                	<input type="hidden" name="mc_cinemaid" value="<{$cinemaid}>" />
                                    <input type="hidden" name="details_id" value="<{$details_id}>" />
				                    <input name="imageField" type="image" src="../img/button_ok.gif" width="60" height="22" class="np" border="0"  style="cursor:pointer; ">
				                </td>
				                <td width="99">
				                	<img src="../img/button_reset.gif" width="60" height="22" border="0" onClick="location.reload();" style="cursor:pointer; ">
				                </td>
			              	</tr>
						</table>
					</td>
    			</tr>
			</table>
		</td>
	</tr>
</table>
</form>
</body>

</html>